﻿using SharpAdbClient;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DroidLord.Core
{
    class DeviceManager
    {
        private static Hashtable mDevOnline = new Hashtable();

        public static Boolean mIsFirstScan = true;

        public static void  addOnlineDevice(string sn,DeviceData deviceData)
        {
            try { 
               mDevOnline.Add(sn, deviceData);
            }catch(Exception eeee)
            {

            }
        }
        public static void removeDevice(string sn)
        {
            mDevOnline.Remove(sn);
        }
        public static Boolean isDeviceOnline(string sn)
        {
            if(mDevOnline.ContainsKey(sn))
            {
                return true;
            }
            return false;
        }
        public static HashSet<string>  getOnlieDeviceIds()
        {
            HashSet<string> idsSet = new HashSet<string>();
            ICollection number = mDevOnline.Keys;
            foreach (string k in number)
            {
                idsSet.Add(k);
            }
            return idsSet;
        }
        public static DeviceData getDeviceData(string sn)
        {
            DeviceData data = null;
            ICollection number = mDevOnline.Keys;
            foreach (string k in number)
            {
                if(k.Equals(sn))
                {
                    data=(DeviceData)mDevOnline[sn];
                    break;
                }
            }
            return data;
        }
    }
}
